package com.frank.oj.service.entity.group.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.frank.model.entity.problem.Problem;
import com.frank.oj.mapper.GroupProblemMapper;
import com.frank.oj.model.vo.ProblemVO;
import com.frank.oj.service.entity.group.GroupProblemEntityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author frank
 * @Date 2024/5/4
 */
@Service
public class GroupProblemEntityServiceImpl implements GroupProblemEntityService {
    @Resource
    private GroupProblemMapper groupProblemMapper;
    @Override
    public IPage<ProblemVO> getProblemList(Integer limit, Integer currentPage, Long gid) {

        IPage<ProblemVO> iPage = new Page<>(currentPage, limit);
        List<ProblemVO> problemList = groupProblemMapper.getProblemList(iPage, gid);

        return iPage.setRecords(problemList);
    }

    @Override
    public IPage<Problem> getAdminProblemList(Integer limit, Integer currentPage, Long gid) {
        IPage<Problem> iPage = new Page<>(currentPage, limit);
        List<Problem> problemList = groupProblemMapper.getAdminProblemList(iPage, gid);

        return iPage.setRecords(problemList);
    }
}
